namespace CSharpPro._1009;
public class Dome
{
    public void TextPrint()
    {    Console.WriteLine("1000以内的水仙花数有：");
        
        for (int i = 100; i < 1000; i++)
        {
            int hundreds = i / 100;
            int tens = (i / 10) % 10;
            int units = i % 10;
            int sum = (int)(Math.Pow(hundreds, 3) + Math.Pow(tens, 3) + Math.Pow(units, 3));
            if (sum == i)
            {
                Console.WriteLine(i);
            }
        }
    }

    public void TextPrint2()
    {
        Console.WriteLine("100以内的质数有：");
        
        for (int i = 2; i <= 100; i++)
        {
            if (IsPrime(i))
            {
                Console.Write(i + " ");
            }
        }
    }
    static bool IsPrime(int number)
    {
        if (number < 2)
            return false;
        if (number == 2)
            return true;
        if (number % 2 == 0)
            return false;
        for (int i = 3; i <= Math.Sqrt(number); i += 2)
        {
            if (number % i == 0)
                return false;
        }
        return true;
    }
}